﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using BUS;
using DTO;


namespace nhahangbarota
{
    public partial class DangNhap : Form
    {
        public DangNhap()
        {
            InitializeComponent();
        }
        private void fDangNhap()
        {
            MatKhauBUS BUS = new MatKhauBUS();
            if (BUS.Somatkhau().Rows[0][0].ToString() == txtMatKhau.Text)
            {

                this.Hide();
                Formchinh fc = new Formchinh();
                fc.ShowDialog();
                this.Hide();
                txtMatKhau.Clear();
            }
            else
            {
                MessageBox.Show("Nhập sai mật khẩu");
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            fDangNhap();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.Hide();
            DoiMatKhau a = new DoiMatKhau();
            a.ShowDialog();
            this.Show();
        }

        private void DangNhap_Load(object sender, EventArgs e)
        {
            txtMatKhau.Focus();
            this.KeyPreview = true;

        }

        private void DangNhap_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                
                fDangNhap();
            }
        }

        private void DangNhap_KeyPress(object sender, KeyPressEventArgs e)
        {
            txtMatKhau.Focus();
        }
    }
}
